package model;

import interfaces.AbstractWish;
import java.util.Iterator;
import java.util.Vector;
import wishes.WishToTakeMedicine;
import enums.WishType;

public class Wishes implements Iterable<AbstractWish> {
	private Vector<AbstractWish> vector;

	public Wishes() {
		vector = new Vector<AbstractWish>();
	}

	public boolean contains(WishType type) {
		for (AbstractWish wish : vector) {
			if (wish.getType() == type) {
				return true;
			}
		}
		return false;
	}
	public boolean contains(String medicine) {
		for (AbstractWish wish : vector) {
			if (wish.getType() == WishType.WishToTakeMedicine && ((WishToTakeMedicine)wish).getMedicine().equals(medicine)) {
				return true;
			}
		}
		return false;
	}

	public AbstractWish get(WishType type) {
		for (AbstractWish wish : vector) {
			if (wish.getType() == type) {
				return wish;
			}
		}
		return null;
	}

	public AbstractWish get(String medicine) {
		for (AbstractWish wish : vector) {
			if (wish instanceof WishToTakeMedicine && ((WishToTakeMedicine) wish).getMedicine().equals(medicine)) {
				return wish;
			}
		}
		return null;
	}

	public boolean remove(AbstractWish wish) {
		return vector.remove(wish);
	}
	public void add(AbstractWish wish) {
		vector.add(wish);
	}

	public int size() {
		return vector.size();
	}

	public boolean isEmpty() {
		return vector.isEmpty();
	}
	public AbstractWish get(int index) {
		return vector.get(index);
	}

	@Override
	public Iterator<AbstractWish> iterator() {
		return vector.iterator();
	}
}
